Skip to content

fix: handle OSError in _get_mtime for non-file paths (fixes #11386)#11392

Open
gaoflow wants to merge 1 commit into
pydata:mainfrom
gaoflow:fix-11386-get-mtime-non-file
Open

fix: handle OSError in _get_mtime for non-file paths (fixes #11386)#11392
gaoflow wants to merge 1 commit into
pydata:mainfrom
gaoflow:fix-11386-get-mtime-non-file

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 17, 2026

Copy link
Copy Markdown

_get_mtime() calls os.path.getmtime() on any non-remote path,
but some paths that look like local filesystem paths are actually
GDAL virtual filesystems (/vsicurl/..., /vsis3/...) or other
URI schemes that don't support stat(). This causes OSError to
propagate and crash open_dataset().

Wrap the getmtime call in contextlib.suppress(OSError) so that
non-file paths gracefully return mtime = None instead of raising.

  • Tests added
  • All tests pass

)

_get_mtime calls os.path.getmtime on any non-remote path, but some
paths that look like local filesystem paths are actually GDAL virtual
filesystems (/vsicurl/..., /vsis3/...) or other URI schemes that
don't support stat(). Wrap the call in suppress(OSError) to avoid
crashing on these paths.
@welcome

welcome Bot commented Jun 17, 2026

Copy link
Copy Markdown

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient.
If you have questions, some answers may be found in our contributing guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant